from fastapi import APIRouter,Form
from .model.LoginModel import LoginModel
from .model.UserModel import UserModel
from datetime import  date

loginScene = APIRouter()

# response_model_exclude_unset 只保留设置的值
@loginScene.post("/login",response_model=UserModel,response_model_exclude_unset=True)
async def login(logindata: LoginModel):
    user = UserModel(name=logindata.username,age=11,birth=date.today(),friends=[1,2,3])
    return user


# 表单数据
@loginScene.post("/wxlogin")
async def wxlogin(username:str = Form(),password:str = Form()):
    print(username,password)
    return {"username":username,"password":password}
